/*
 * @Description:
 * @Author: ldx
 * @Date: 2022-09-17 22:04:14
 * @LastEditors: ldx
 * @LastEditTime: 2022-09-24 19:42:32
 */
import axios from '@/utils/axios'

import { Pagination } from '../types'
/** 角色分页列表 */
export async function queryRoleList(
  { current, pageSize }: Pagination,
  params: any
): Promise<any> {
  return axios
    .post<any & Pagination, any>(`/ivr/role/page`, {
      ...params,
      pageSize,
      pageNum: current
    })
    .then((res) => ({
      total: res.data.total,
      list: res.data.records
    }))
}
/** 角色删除 */
export const deleteRole = (id: string): Promise<any> => {
  return axios.post<unknown, any>(`/ivr/role/delete/${id}`)
}
/** 角色关联权限 */
export const relateAccess = (id: string, data: any): Promise<any> => {
  return axios.post<unknown, any>(`/ivr/role/relate-access/${id}`, data)
}
/** 角色详情 */
export const queryDetails = (id: string): Promise<any> => {
  return axios.get<any & Pagination, any>(`/ivr/role/details/${id}`)
}
/** 创建角色 */
export const createRole = (data: any): Promise<any> => {
  return axios.post<any & Pagination, any>(`/ivr/role/create`, data)
}
/** 角色修改 */
export const updateRole = (data: any): Promise<any> => {
  return axios.post<any & Pagination, any>(`/ivr/role/update`, data)
}
/** 权限列表 */
export const queryAccess = (params: any): Promise<any> => {
  return axios.post<any & Pagination, any>(`/ivr/access/simple/list`, {
    ...params,
    pageSize: 1000,
    pageNum: 1
  })
}
